home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue26 / directx / DDUTILS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-07-22  |  1.6 KB  |  56 lines

  1. unit DDUtils;
  2.  
  3. interface
  4.  
  5. uses Windows, Classes, SysUtils, DirectX, ComObj;
  6.  
  7. type
  8.  
  9. EDDError = Exception;
  10. ED3DRMError = Exception;
  11.  
  12. procedure DDCheck(Result: HResult);
  13. procedure D3DRMCheck(Result: HResult);
  14.  
  15. implementation
  16.  
  17. procedure D3DRMError(ErrorCode: HResult);
  18. var
  19.   ErrMsg: String;
  20. begin
  21.   case ErrorCode of
  22.     D3DRMERR_BADALLOC:        ErrMsg := 'Out of memory.';
  23.     D3DRMERR_BADDEVICE:       ErrMsg := 'Device is not compatible with renderer.';
  24.     D3DRMERR_BADFILE:         ErrMsg := 'Data file is corrupt.';
  25.     D3DRMERR_BADMAJORVERSION: ErrMsg := 'Bad DLL major version.';
  26.     D3DRMERR_BADMINORVERSION: ErrMsg := 'Bad DLL minor version.';
  27.     D3DRMERR_BADOBJECT:       ErrMsg := 'Object expected in argument.';
  28.     D3DRMERR_BADTYPE:         ErrMsg := 'Bad argument type passed.';
  29.     D3DRMERR_BADVALUE:        ErrMsg := 'Bad argument value passed.';
  30.     D3DRMERR_FACEUSED:        ErrMsg := 'Face already used in a mesh.';
  31.     D3DRMERR_FILENOTFOUND:    ErrMsg := 'File cannot be opened.';
  32.     D3DRMERR_NOTDONEYET:      ErrMsg := 'Unimplemented.';
  33.     D3DRMERR_NOTFOUND:        ErrMsg := 'Object not found in specified place.';
  34.     D3DRMERR_UNABLETOEXECUTE: ErrMsg := 'Unable to carry out procedure.';
  35.   end;
  36.   ErrMsg := 'DirectDraw 3D Retained Mode error: ' + ErrMsg;
  37.   raise ED3DRMError.Create(ErrMsg);
  38. end;
  39.  
  40. procedure D3DRMCheck(Result: HResult);
  41. begin
  42.   if Result <> D3DRM_OK then D3DRMError(Result);
  43. end;
  44.  
  45. procedure DDError(ErrorCode: HResult);
  46. begin
  47.   raise EDDError.Create('DirectDraw error');
  48. end;
  49.  
  50. procedure DDCheck(Result: HResult);
  51. begin
  52.   if Result <> DD_OK then DDError(Result);
  53. end;
  54.  
  55. end.
  56.